import time
from random import shuffle

class insertionsortClass():
	"""docstring for bubblesort"""
	def __init__(self, array):
		#super(bubblesort, self).__init__()
		self.array = array
		#self.bubbleSort()

	def insertionSort(self):
		"""
		"""
		start = time.clock()
		for j in xrange(0, len(self.array)):
			key = self.array[j]
			i = j - 1
			while i >= 0 and self.array[i] > key:
				self.array[i+1] = self.array[i]
				i = i - 1
			self.array[i+1] = key

		stop = time.clock()
		print "Tempo inicial: {0} segundos".format(start)
		print "Tempo final  : {0} segundos".format(stop)
		print "Tempo total  : {0} segundos!".format(stop -start)
		return self.array



if __name__ == "__main__":
	lista=[]
	for i in xrange(1, 20):
		lista.append(i)
	#lista=[16,4,10,14,7,9,3,2,1,8]
	shuffle(lista)
	
	print '** Insertionsort **\nLista Inicial : ', lista
	insertionsortObject = insertionsortClass(lista)
	sortedArray = insertionsortObject.insertionSort()
	print 'Lista Ordenada: ', sortedArray